from collections import Counter

# 请在此输入您的代码
n, x = map(int, input().split())
nums = list(map(int, input().split()))
counter = Counter(nums)
ans = 0
for key, value in counter.items():
    ans = max(ans, min(value, x) * key)
print(ans)
